<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body style="background-color: #F5F6F7">
<div class="container" style="background-color:white;margin-top: 20px">
    <form id="form" style="margin:10px 0px 10px">
        <span style="font-size:larger;color: black">修改站点</span>
        <hr style="border: black 1px solid">
        <div class="form-group">
            <label for="siteId">站点ID</label>
            <input type="text" class="form-control" name="siteId" id="siteId" placeholder="请输入站点ID">
        </div>

        <button id="find"  type="button" class="btn btn-danger form-control ">查询</button>
        <div id="success">
        <div class="form-group">
            <label for="siteName">站点名</label>
            <input type="text" class="form-control" name="siteName" id="siteName" placeholder="请输入站点名">
        </div>
        <div class="form-group">
            <label for="sitePhone">站点电话</label>
            <input type="text" class="form-control" name="sitePhone" id="sitePhone" placeholder="请输入站点电话">
        </div>
        <div class="form-group">
            <div style="width: 33%;display: inline-block">
                <label for="proId">站点省ID</label>
                <input type="text" class="form-control" name="proId" id="proId" placeholder="请输入站点省ID">
            </div>
            <div style="width: 33%;display: inline-block">
                <label for="cityId">站点市ID</label>
                <input type="text" class="form-control" name="cityId" id="cityId" placeholder="请输入站点市ID">
            </div>
            <div style="width: 33%;display: inline-block">
                <label for="areaId">站点区ID</label>
                <input type="text" class="form-control" name="areaId" id="areaId" placeholder="请输入站点区ID">
            </div>
        </div>
        <button type="submit" class="btn btn-danger form-control ">修改</button>
            </div>
    </form>
</div>
<script src="../js/jquery-3.3.1.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/distpicker.data.js"></script>
<script src="../js/distpicker.js"></script>
<script src="../js/distpicker.data.js"></script>
<script src="../js/distpicker.js"></script>
<script src="../layer/layer.js"></script>
<script>
    $(function(){
        $("#success").hide();
        $("#find").click(function(){
            var siteId = $("#siteId").val();
            $.getJSON("../adminSelectSite.do",{siteId:siteId},function(data){
                console.log(data)
                layer.msg(data.message);
                if(data.message == "查询成功"){
                    $("#success").show();
                    $("#find").hide();
                }
                $("#siteName").val(data.data[0].siteName);
                $("#proId").val(data.data[0].proId);
                // $("#areId").val(data.data[0].areId);
                $("#cityId").val(data.data[0].cityId);
                $("#sitePhone").val(data.data[0].sitePhone);
            })
        });

        $("#form").submit(function(){
            let siteName = $("#siteName").val();
            let proId = $("#proId").val();
            let areId = $("#areId").val();
            let cityId = $("#cityId").val();
            let sitePhone = $("#sitePhone").val();
            $.post("../adminUpdateSite.do",{
                siteName:siteName,
                proId:proId,
                areId:areId,
                cityId:cityId,
                sitePhone:sitePhone
            },function(data){
                //layer.msg(data.data.message);
                console.log(data)
                if(data.code == 1){
                    //录入成功
                    layer.msg("修改成功");
                    $("input").val("");
                    // $("input:eq(1)").val("顺丰速运");
                }else{
                    layer.msg("修改失败");
                    //录入失败
                }
            });
            return false
        });
    });
</script>
</body>
</html>